
package org.interview.reflection.hashcode;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class PojoIncorrectHCTest
{
	private static final long count = 1;

	public static void main(String[] args)
	{

	List<PojoIncorrectHC> list = PojoGenerator.generatePojoIncorrectHC(count);
		
		Map<PojoIncorrectHC, String> map = new HashMap<PojoIncorrectHC, String>();
		
		for (PojoIncorrectHC pojoIncorrectHC : list) {
			//System.out.println(pojoIncorrectHC.hashCode());
			map.put(pojoIncorrectHC, pojoIncorrectHC.getName());
		}
		
		System.out.println("collection size : " + map.size());
		
		long start = System.currentTimeMillis();
		for (PojoIncorrectHC pojoIncorrectHC : list) {
			
			PojoIncorrectHC pojoIncorrectHCForSearch = new PojoIncorrectHC();
			pojoIncorrectHCForSearch.setId(pojoIncorrectHC.getId());
			String value = map.get(pojoIncorrectHCForSearch);
			if (value == null || !value.equals(pojoIncorrectHC.getName()))
			{
				System.out.println("error: pojo found wrong");
				System.out.println("pojoIncorrectHC hashcode = " + pojoIncorrectHC.hashCode());
				System.out.println("pojoIncorrectHCForSearch hashcode = " + pojoIncorrectHCForSearch.hashCode());
				
			}
		}
		long finish = System.currentTimeMillis();
		long result = finish - start;
		System.out.println("Result = " + result + " ms");

	}
		
	

}
